package com.ctshk.rpc.visa.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.ctshk.rpc.visa.entity.Visa;
import com.ctshk.rpc.visa.req.visa.TripVisaDTO;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
 * <p>
 * 签证资源 Mapper 接口
 * </p>
 *
 * @author 谢诗宏
 * @since 2021-01-20
 */
public interface VisaMapper extends BaseMapper<Visa> {

    /**
     * 根据ID列表获取签证详情
     * @param visaIdList
     * @return
     */
    @Select("<script>"+"SELECT b.id AS visa_id,b.`name`,c.cost_amount,c.currency_id,c.currency,c.planned_exchange_rate,d.adjust_type,d.amount,d.percent \n" +
            "FROM t_visa b\n" +
            "LEFT JOIN t_visa_type c ON b.id = c.visa_id\n" +
            "LEFT JOIN t_visa_product d ON b.id = d.visa_id\n" +
            "WHERE b.is_deleted = 0 AND b.id IN " +
            "<foreach collection=\"list\" item=\"id\" index=\"index\" open=\"(\" close=\")\" separator=\",\">\n" +
            "#{id}\n" +
            "</foreach>"+
            "</script>")
    List<TripVisaDTO> queryByIdList(@Param("list") List<Long> visaIdList);
}
